// use clap::{App, Arg};
#[macro_use]
extern crate derive_builder;
extern crate log;
extern crate pretty_env_logger;
extern crate subprocess;

use std::collections::HashMap;

use clap::Parser;
use log::info;
use rdkafka::util::get_rdkafka_version;

use app::Cli;

use crate::processor::consume_and_send;
use crate::utils::get_serial_numb;

mod app;
mod consumer;
mod processor;
mod structs;
mod utils;

#[tokio::main]
async fn main() {
    pretty_env_logger::init();
    let cli = Cli::parse();
    let (version_n, version_s) = get_rdkafka_version();
    info!("rd_kafka_version: 0x{:08x}, {}", version_n, version_s);
    consume_and_send(
        cli.get_psb_host(),
        &get_serial_numb(),
        &[cli.get_psb_topic()],
        cli.get_psb_username().as_deref(),
        cli.get_psb_password(),
    )
    .await
}
